const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
//引入路由器文件
const usersRouter = require('./router/user');

const app = express();
//暴露
app.use(express.static('public'));
//跨域
app.use(cors());
//将post请求的请求体放到req.body上
app.use(bodyParser.urlencoded({extended:true}));

app.use(usersRouter);

app.listen(3000,err=>{
    if(!err) console.log('服务器启动成功！');
    else console.log(err);
})